var e = getApp();

Page({
    data: {
        name: "",
        img: "",
        title: "",
        fromGood: "",
        is_bind_invite: 0,
        lk: 0,
        parent_id: ""
    },
    onLoad: function(t) {
        if (t.scene) {
            var a = decodeURIComponent(t.scene);
            if (a) {
                var i = [];
                i = a.split("&");
                for (var n = 0; n < i.length; n++) {
                    var o;
                    "m" == (o = i[n].split("="))[0] ? e._setMid(o[1]) : "lk" == o[0] && this.setData({
                        lk: o[1]
                    });
                }
            }
        }
    },
    onReady: function() {},
    onShow: function() {
        this.getUserinfo(), this.showName();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getUserinfo: function() {
        var t = this, a = "";
        try {
            var i = wx.getStorageSync("mid");
            i && (a = i);
        } catch (e) {}
        var n = e.getNetAddresss("member.member.getUserInfo");
        e._getNetWork({
            url: n,
            data: {
                mid: a
            },
            validateBol: 2,
            success: function(e) {
                var a = e.data;
                1 == a.result && t.setData({
                    parent_id: a.data.yz_member.parent_id,
                    name: a.data.referral.nickname,
                    img: a.data.referral.avatar,
                    is_bind_invite: a.data.is_bind_invite,
                    inviteCode: a.data.inviteCode
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    showName: function() {
        var t = this, a = e.getNetAddresss("member.member.getShopSet");
        e._getNetWork({
            url: a,
            data: {},
            validateBol: 2,
            success: function(e) {
                var a = e.data;
                1 == a.result ? t.setData({
                    title: a.data.shop_set_name,
                    default_invite: a.data.default_invite
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    affirm: function() {
        var t = this;
        try {
            wx.setStorageSync("isset", 1);
        } catch (e) {
            console.log(e);
        }
        if (1 == this.data.fromGood) {
            var a = e.getNetAddresss("member.member.confirmGoods");
            e._getNetWork({
                url: a,
                data: {},
                success: function(e) {
                    var t = e.data;
                    1 == t.result ? wx.navigateBack({
                        delta: 1
                    }) : wx.showToast({
                        icon: "none",
                        title: t.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        } else e._getNetWork({
            url: e.getNetAddresss("member.member.update-member-invite"),
            data: {
                parent_id: this.data.parent_id
            },
            success: function(a) {
                if (1 == a.data.result) {
                    if (1 == t.data.lk) return void wx.navigateTo({
                        url: "/packageF/sign_in_subscribe/index/index"
                    });
                    wx.navigateTo({
                        url: "/packageA/member/editmobile/editmobile?fromApp=3&code=" + t.data.inviteCode
                    });
                } else e.tips(a.data.msg);
            }
        });
    }
});